Skip to content

[#828] Fix infinite loop picking the errors-encountered LDIF file name - #839

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/828-ldif-connhandler-infinite-loop
Aug 4, 2026
Merged

[#828] Fix infinite loop picking the errors-encountered LDIF file name#839
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/828-ldif-connhandler-infinite-loop

Conversation

@vharseko

@vharseko vharseko commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #828.

LDIFConnectionHandler.processLDIFFile() never left the loop which picks a free .errors-encountered.<timestamp> name: it had no break, and every iteration whose candidate was free appended another numeric suffix, so the handler thread hung and the path string grew until OutOfMemoryError. The twin block for the .applied name a few lines above has the intended break, which confirms the loop shape that was meant here.

Changes:

  • Both name-picking blocks (.applied and .errors-encountered) are replaced with a single package-private helper selectUnusedPath(), which stops at the first free name.
  • The rename of a failed source file now goes through StaticUtils.renameFile(), and the delete of an applied source file through Files.delete(), so a failure throws and the existing catch blocks finally log ERR_LDIF_CONNHANDLER_CANNOT_RENAME / ERR_LDIF_CONNHANDLER_CANNOT_DELETE and raise the alert instead of silently ignoring the returned false. The renameFile line is textually identical to the one in Fix CodeQL note-severity alerts: ignored error status of file and stream calls #814, so the two PRs merge cleanly in either order.

Tests:

  • testSelectUnusedPath — unit test of the helper: a free base name is used as-is, a taken one gets .2, and with .2/.3 taken the helper picks .4 with exactly one suffix appended (the old loop kept stacking suffixes).
  • testUnparseableLDIFErrorsNameTaken — end-to-end reproduction of LDIF connection handler hangs in an infinite loop when the .errors-encountered file name is taken #828: every .errors-encountered.<timestamp> name the handler may pick is pre-created, and the unparseable file must still be renamed to the .2 variant. With the old code this test hangs the handler thread.

LDIFConnectionHandlerTestCase: 6/6 passed (mvn -pl opendj-server-legacy -P precommit verify -Dit.test=LDIFConnectionHandlerTestCase).

…ntered LDIF file name

The loop in LDIFConnectionHandler.processLDIFFile() which picks a free
.errors-encountered.<timestamp> name never terminated: it had no break
and kept appending numeric suffixes, hanging the handler thread and
growing the path string until OutOfMemoryError.

Replace both name-picking blocks (.applied and .errors-encountered) with
a single testable helper which stops at the first free name.  The rename
and delete of the source file now use StaticUtils.renameFile() and
Files.delete(), so a failure is logged and raises an alert instead of
being silently ignored.
@vharseko vharseko added bug java Pull requests that update java code tests Test suites: fixing, enabling, un-disabling labels Aug 3, 2026
@vharseko
vharseko requested a review from maximthomas August 3, 2026 20:41
@vharseko
vharseko merged commit fc0edcb into OpenIdentityPlatform:master Aug 4, 2026
17 checks passed
@vharseko
vharseko deleted the issues/828-ldif-connhandler-infinite-loop branch August 4, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug java Pull requests that update java code tests Test suites: fixing, enabling, un-disabling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LDIF connection handler hangs in an infinite loop when the .errors-encountered file name is taken

2 participants